/* 代码块全局样式 */
pre {
    position: relative;
    margin: 1em 0;
    padding: 1.5em 1em 1em;
    background-color: #1e1e1e !important;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-height: 350px;
    transition: max-height 0.3s ease;

    &.expanded {
        max-height: none;
    }

    /* 复制按钮样式 */
    .code-copy-btn {
        position: absolute;
        top: 3px;
        left: 10px;
        padding: 4px 8px;
        font-size: 12px;
        color: #d4d4d4;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        cursor: pointer;
        opacity: 0;
        transition: all 0.2s ease;
        
        &:hover {
            background: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.3);
        }
        
        &.copied {
            background: #28a745;
            border-color: #28a745;
            color: white;
            opacity: 1;
        }
    }

    /* 展开按钮样式 */
    .code-expand-btn {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: linear-gradient(transparent, #1e1e1e 40%);
        display: flex;
        align-items: flex-end;
        justify-content: center;
        cursor: pointer;
        opacity: 1;
        padding-bottom: 10px;

        &::after {
            content: '展开代码';
            color: #fff;
            font-size: 13px;
            padding: 4px 12px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 4px;
            border: 1px solid rgba(255, 255, 255, 0.3);
            transition: all 0.2s ease;
        }

        &:hover::after {
            background: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.4);
        }

        &.expanded::after {
            content: '收起代码';
        }
    }

    &:hover .code-copy-btn {
        opacity: 1;
    }

    /* 代码块本身的样式 */
    code {
        display: block;
        font-family: Consolas, Monaco, 'Courier New', monospace;
        font-size: 14px;
        line-height: 1.5;
        padding: 0;
        margin: 0;
        overflow-x: auto;
        white-space: pre;
        word-break: normal;
        word-wrap: normal;
        color: #d4d4d4;
        
        &.hljs {
            padding: 0;
            background: transparent;
        }
    }

    /* 语言标签 */
    &[class*="language-"]::before {
        content: attr(class);
        position: absolute;
        top: 0;
        left: 8px;
        padding: 4px 8px;
        font-size: 12px;
        color: #d4d4d4;
        background: #2d2d2d;
        border-bottom-right-radius: 4px;
        border-bottom-left-radius: 4px;
        text-transform: uppercase;
        transform: lowercase;
        opacity: 0.7;
    }
}